package com.neusoft.demo2;

public class PopSort {
    public static int[] sort(int[] array) {
        for(int i = 1;i<array.length;i++) { //控制总的比较次数
            for(int j = 0;j < array.length-i;j++) {  //相邻的两个元素比较，如果满足条件，互换位置
                if(array[j] > array[j+1]) {
                    int temp = array[j];
                    array[j] = array[j+1];
                    array[j+1] = temp;
                }
            }
        }
        return array;
    }

    public static int[] sum(int[] arr) {
        //int[] arr = {1,2,3,4,5,6,7,8,9,10};
        int jishu = 0;
        int oushu = 0;
        for(int i = 0;i<arr.length;i++) {
            if(arr[i] % 2 == 0) {
                oushu += arr[i];
            }else {
                jishu += arr[i];
            }
        }
        int[] x = {jishu,oushu};
        //        int[] a = new int[3];
        //        int aa = 1;
        //        a[0] = aa;
        return x;
    }

    public static void main(String[] args) {
        int[] array = {1,7,22,14,8,16,10};
        int[] result = sum(array);
        for (int i:result) {
            System.out.println(i);
        }




        int[] a = sort(array);
        for(int i = 0;i<a.length;i++){
            System.out.println(a[i]);
        }

        //已知一个数组[1,2,3,4,5,6,7,8,9,10] 计算数组的奇数和与偶数和
        //1. 方法如何定义
        //2. 有没有参数和返回值类型
        //3. 调用方法



    }
}
